@extends('admin.layout.common')
@section('content')
    <link rel="stylesheet" type="text/css" href="{{asset('/css/system/advertising.css')}}">
			<div class="content">
				<h1 class="h1">广告管理</h1>
				<button	type="button" class="btn add">添加</button>
        <table border="1" width="100%">
            <thead>
            <tr>
                <th style="min-width:150px;">ID</th>
                <th style="min-width:150px;">名称</th>
                <th style="min-width:150px;">创建时间</th>
                <th style="min-width:150px;">状态</th>
                <th style="min-width:150px;">操作</th>
            </tr>
            </thead>
            @foreach($list as $v)
            <tr id="datatable-responsive" class="id">
                <td style="border:1px solid #ccc;">{{$v->id}}</td>
                <td style="border:1px solid #ccc;">{{$v->name}}</td>
                <td style="border:1px solid #ccc;">{{$v->create_time}}</td>
                    @if($v->status==0)
                        <td style="border:1px solid #ccc;">禁用中</td>
                    @elseif($v->status==1)
                        <td style="border:1px solid #ccc;">启用中</td>
					@endif
                <td style="border:1px solid #ccc;">
                    <input type="button" name="" value="编辑/查看" class="btn layui-btn layui-btn-radius layui-btn-primary" style="-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;color:#555;" onclick=edit({{$v->id}})>
                    @if($v->status==0)
                        <input type="button" name="" value="启用" class="btn redact layui-btn layui-btn-radius" style="-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;"  onclick="enable({{$v->id}})">
                    @elseif($v->status==1)
                        <input type="button" name="" value="禁用" class="btn_shanchu btn forbidden" onclick="disable({{$v->id}})">
					@endif
                    <input type="button" name="" value="删除" class="btn_shanchu btn delete" onclick="deleteAdv({{$v->id}})">
                    
                </td>
            </tr>
            @endforeach
        </table>
        {{ $list->links()}}
    </div>
<script type="text/javascript" src="{{URL::asset('js/layui-v2.3.0/layui/layui.all.js')}}"></script>
<link rel="stylesheet" href="{{URL::asset('css/app.css')}}">
<script type="text/javascript" src="{{asset('js/system/advertising.js')}}"></script>
<script>
// 启用弹窗
        function enable($id) {
            layer.open({
                type: 2,
                area: ['500px', '300px'],
                content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/enableAdv/2'
                , btn: ['确定', '取消']
                , yes: function (index, layero) {
                    $.get('http://{{$_SERVER['HTTP_HOST']}}/admin/enableAdv/' + $id, function (data) {
                        location.reload();
                    })
                }
            })
        }
        // 禁用弹窗
        function disable($id) {
            layer.open({
                type: 2,
                area: ['500px', '300px'],
                content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/disableAdv/3'
                , btn: ['确定', '取消']
                , yes: function (index, layero) {
                    $.get('http://{{$_SERVER['HTTP_HOST']}}/admin/disableAdv/' + $id, function (data) {
                        location.reload();
                    })
                }
            })
        }
        // 删除弹窗
        function deleteAdv($id) {
            layer.open({
                type: 2,
                area: ['500px', '300px'],
                content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/deleteAdv/4'
                , btn: ['确定', '取消']
                , yes: function (index, layero) {
                    $.get('http://{{$_SERVER['HTTP_HOST']}}/admin/deleteAdv/' + $id, function (data) {
                        location.reload();
                    })
                }
            })
        }

// 点击添加弹窗
$(".add").on("click",function(){
    layer.open({
        type:2,
        shadeClose: true, //点击遮罩关闭
        skin: 'layui-layer-rim', //加上边框
        area: ['1400px', '400px'], //宽高
        content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/addAdv'
        ,end: function () {
            location.reload();
        }
    });
});

//编辑
function edit($id) {
    layer.open({
        type: 2,
        shadeClose: true, //点击遮罩关闭
        skin: 'layui-layer-rim', //加上边框
        area: ['1400px', '450px'], //宽高
        content: "http://{{$_SERVER['HTTP_HOST']}}/admin/editAdv/"+$id
        ,end: function () {
            location.reload();
        }
    });
}
</script>
@endsection

